import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    list:[]
  },
  getters: {
    
  },
  mutations: {
    add1(state,good){
      let i = state.list.findIndex(i => i.id == good.id)
      if(i == -1){
        good.num = 2
        state.list.push(good)
      }else{
        good.num++
      }
    },
    tap1(state,good){
      let i = state.list.findIndex(i => i.id == good.id)
      if(i == -1){
        state.list.push(good)
      }else{
        if(good.num == 0) return
        good.num--
        
      }

    }
  },
  actions: {
  },
  modules: {
  }
})
